package com.zhaoyuxi;

import com.zhaoyuxi.redpack.entity.TbRedpack;
import com.zhaoyuxi.redpack.service.ITbRedpackService;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.ValueOperations;

@SpringBootApplication
@MapperScan("com.zhaoyuxi.redpack.mapper")
public class MessageApplication implements CommandLineRunner {


    @Autowired
    RedisTemplate redisTemplate;

    @Autowired
    ITbRedpackService tbRedpackService;

    public static void main(String[] args) {
        SpringApplication.run(MessageApplication.class,args);
    }

    @Override
    public void run(String... args) throws Exception {
        TbRedpack one = tbRedpackService.getOne(1);
        ValueOperations valueOperations = redisTemplate.opsForValue();
        valueOperations.set("redpack",one);
    }
}
